package com.pf.core.xml;

import java.io.InputStream;
import java.util.Map;

import org.w3c.dom.Node;

import com.pf.core.pojo.Action;
import com.pf.core.pojo.ActionConfig;
import com.pf.core.util.PfNodeUtil;
import com.pf.core.util.ReflectUtil;

public class PfActionConfigParser {
	private PfNodeParser parser=new PfNodeParser();
	public PfActionConfigParser(){
		getAction();
	}

	public void parse(InputStream inputStream) throws Exception{
	    parser.parse(inputStream);
	}

	private void getAction(){
		parser.addNodelet("/pf/action", new PfNode(){
			public void execute(Node node) {
				Map<String,String> map=PfNodeUtil.getAtts(node);
				try {
					Action action=ReflectUtil.mapToBean(map,Action.class);
					ActionConfig.getInstance().put(action);
				} catch (Exception e) {

				}
			}
		});

	}


}
